package com.fs.json;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fs.json.basequ.BaseQuDto;
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Test;

/**
 * @author shuai.fang
 * @date：2017-06-08
 * @description：
 */
public class TestJson {

	@Test
	public void test() {
		String jsona = "{name : 'fs', state : ''}";
		JSONObject jsonObject = JSON.parseObject(jsona);
		jsonObject.put("state", "afddsf");
		System.out.println(jsonObject.toString());
	}

	@Test
	public void testSign() {
		String str = "fsffsfssf";
		System.out.println(new String(DigestUtils.getSha1Digest().digest(str.getBytes())));
		System.out.println(new String(DigestUtils.getSha1Digest().digest(str.getBytes())));
		System.out.println(new String(DigestUtils.getSha1Digest().digest(str.getBytes())));
		System.out.println(new String(DigestUtils.getSha1Digest().digest(str.getBytes())));
		System.out.println(new String(DigestUtils.getSha1Digest().digest(str.getBytes())));
	}

	@Test
	public void testParseArray() {
		String jsonStr = "[{\"id\":1098,\"question\":\"雇佣关系核查是否通过\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null},{\"id\":1099,\"question\":\"公司地址核查是否通过\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null},{\"id\":1100,\"question\":\"本人核查是否通过\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null},{\"id\":1101,\"question\":\"身份证核查是否通过\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null},{\"id\":1102,\"question\":\"微信号/QQ号负面信息核查是否通过\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null},{\"id\":1103,\"question\":\"客户贷款用途\",\"remark\":\"\",\"baseQuAnswerDtoList\":[\"\"],\"auditPoint\":null,\"type\":null}]";

		JSONArray jsonArray = JSON.parseArray(jsonStr);
		for (int i = 0; i < jsonArray.size(); i++) {
			BaseQuDto baseQuDto = jsonArray.getObject(i, BaseQuDto.class);
			System.out.println(baseQuDto);
		}
	}

}
